/**============================================================================
 Confidential Information - Limited distribution to authorized persons only.
 This software is protected as an unpublished work under the U.S. Copyright
 Act of 1976.

 Copyright (c) 2011, BluePhoenix Solutions, Inc. All rights reserved.
 ----------------------------------------------------------------------------
 file......: BaseSwingButton.java
 Author....: Vyacheslav Kovalyov
 Created...: 22.10.11

 Description:

 ============================================================================*/
package ru.monyag.pred.swing.ui.buttons;

import ru.monyag.pred.swing.util.IconManager;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * @author Vyacheslav Kovalyov
 * @version 1.0
 */
public abstract class BaseSwingButton extends JButton {

    protected BaseSwingButton(String iconKey, float alignment) {
        this(iconKey);
        setAlignmentX(alignment);
    }

    public BaseSwingButton(String iconKey) {

        setIcon(IconManager.getIcon(iconKey));

        addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                onClick();
            }
        });
    }

    public abstract void onClick();
}
